<?php
/*
 * Created on 2011-3-30
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 $topsdk = dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'TopSdk.php';
 include($topsdk);
 
 class TaobaoUtils
 {
 	const APP_KEY = '12227204';
 	const APP_SECRET = '385459a5b3fed1b80336a290eaa228d5';
 	private $c;
 	
 	public function __construct()
 	{
 		$this->c = new TopClient;
		$this->c->appkey = TaobaoUtils::APP_KEY;
		$this->c->secretKey = TaobaoUtils::APP_SECRET;
		//$this->c->gatewayUrl = "http://gw.api.tbsandbox.com/router/rest";
		$this->c->format = "json";
 	}
 	
 	public function getItems($key, $pageNo, $pageSize)
 	{
 		$req = new TaobaokeItemsGetRequest;
		$req->setFields("num_iid, title, nick, pic_url, click_url");
		$req->setNick("赤珠子");
//		$req->setPid("mm_123456_0_0");
		$req->setKeyword($key);
//		$req->setCid(123);
//		$req->setStartPrice("1");
//		$req->setEndPrice("999");
//		$req->setAutoSend("true");
//		$req->setArea("杭州");
//		$req->setStartCredit("1heart");
//		$req->setEndCredit("1heart");
//		$req->setSort("price_desc");
//		$req->setGuarantee("true");
//		$req->setStartCommissionRate("1234");
//		$req->setEndCommissionRate("2345");
//		$req->setStartCommissionNum("1000");
//		$req->setEndCommissionNum("10000");
//		$req->setStartTotalnum("1");
//		$req->setEndTotalnum("10");
//		$req->setCashCoupon("true");
//		$req->setVipCard("true");
//		$req->setOverseasItem("true");
		$req->setSevendaysReturn("true");
//		$req->setRealDescribe("true");
//		$req->setOnemonthRepair("true");
//		$req->setCashOndelivery("true");
//		$req->setMallItem("true");
		$req->setPageNo($pageNo);
		$req->setPageSize($pageSize);
//		$req->setOuterCode("abc");
//		$req->setIsMobile("true");
		return $this->c->execute($req);
 	}
 }
?>
